import Collection from './base'

export const Interfaces = new Collection({
  name: 'interfaces',
  publish: [
    {
      name: 'interfaces',
      callback (projectId) {
        return Interfaces.find({
          projectId
        })
      }
    }
  ],
  schema: {
    name: { type: String },
    type: { type: Number }, // 0表示目录 1表示接口
    // sort: { type: Number },
    projectId: { type: String },
    parentId: { type: String, optional: true },
    describe: { type: String, optional: true },
    creator: { type: String },
    data: {
      type: Object,
      optional: true,
      blackbox: true
    },
    createDate: {
      type: Date,
      autoValue: function () {
        if (this.isInsert) {
          return new Date()
        }
      }
    },
    updateDate: {
      type: Date,
      autoValue: () => {
        return new Date()
      }
    }
  }
})
